﻿package core.manager
{
    import flash.net.*;
    import flash.utils.*;

    public class NetworkManager extends Object
    {
        private var file:FileReference;
        private var uploadURL:URLRequest;

        public function NetworkManager()
        {
            return;
        }// end function

        public function GenerateRequest(core.manager:NetworkManager:String, core.manager:NetworkManager:ByteArray, core.manager:NetworkManager:String, core.manager:NetworkManager:Dictionary, core.manager:NetworkManager:String = "image") : URLRequest
        {
            var _loc_6:int = 0;
            var _loc_7:String = null;
            var _loc_8:String = null;
            var _loc_9:* = "--";
            var _loc_10:* = new URLRequest();
            var _loc_11:* = new ByteArray();
            _loc_6 = 0;
            while (_loc_6 < 16)
            {
                
                _loc_9 = _loc_9 + String.fromCharCode(int(97 + Math.random() * 25));
                _loc_6++;
            }
            _loc_10.url = core.manager:NetworkManager;
            _loc_10.contentType = "multipart/form-data; boundary=" + _loc_9;
            _loc_10.method = URLRequestMethod.POST;
            _loc_11.endian = Endian.BIG_ENDIAN;
            for (_loc_8 in core.manager:NetworkManager)
            {
                
                _loc_11.writeShort(11565);
                _loc_6 = 0;
                while (_loc_6 < _loc_9.length)
                {
                    
                    _loc_11.writeByte(_loc_9.charCodeAt(_loc_6));
                    _loc_6++;
                }
                _loc_11.writeShort(3338);
                _loc_7 = "Content-Disposition: form-data; name=\"" + _loc_8 + "\"";
                _loc_6 = 0;
                while (_loc_6 < _loc_7.length)
                {
                    
                    _loc_11.writeByte(_loc_7.charCodeAt(_loc_6));
                    _loc_6++;
                }
                _loc_11.writeInt(218762506);
                _loc_11.writeUTFBytes(core.manager:NetworkManager[_loc_8]);
                _loc_11.writeShort(3338);
            }
            _loc_11.writeShort(11565);
            _loc_6 = 0;
            while (_loc_6 < _loc_9.length)
            {
                
                _loc_11.writeByte(_loc_9.charCodeAt(_loc_6));
                _loc_6++;
            }
            _loc_11.writeShort(3338);
            _loc_7 = "Content-Disposition: form-data; name=\"" + core.manager:NetworkManager + "\"; filename=\"";
            _loc_6 = 0;
            while (_loc_6 < _loc_7.length)
            {
                
                _loc_11.writeByte(_loc_7.charCodeAt(_loc_6));
                _loc_6++;
            }
            _loc_11.writeUTFBytes(core.manager:NetworkManager);
            _loc_11.writeByte(34);
            _loc_11.writeShort(3338);
            _loc_7 = "Content-Type: application/octet-stream";
            _loc_6 = 0;
            while (_loc_6 < _loc_7.length)
            {
                
                _loc_11.writeByte(_loc_7.charCodeAt(_loc_6));
                _loc_6++;
            }
            _loc_11.writeInt(218762506);
            _loc_11.writeBytes(core.manager:NetworkManager, 0, core.manager:NetworkManager.length);
            _loc_11.writeShort(3338);
            _loc_11.writeShort(11565);
            _loc_6 = 0;
            while (_loc_6 < _loc_9.length)
            {
                
                _loc_11.writeByte(_loc_9.charCodeAt(_loc_6));
                _loc_6++;
            }
            _loc_11.writeShort(3338);
            _loc_10.data = _loc_11;
            _loc_10.requestHeaders.push(new URLRequestHeader("Cache-Control", "no-cache"));
            return _loc_10;
        }// end function

    }
}
